<?php
declare(strict_types=1);

namespace App\Common\Command;

use App\Sys;
use Hyperf\Command\Annotation\Command;

#[Command]
class AppCommand extends \Hyperf\Command\Command
{

    /**
     * 执行的命令行
     *
     * @var null|string
     */
    protected ?string $name = 'app';


    public function __construct(string $name = null)
    {
        parent::__construct($name);
        $this->setDescription('项目助手');
    }


    public function handle(): void
    {
        $choice = ['取消', '清理缓存'];
        $handle = $this->choice('请选择操作', $choice, 0);
        switch ($handle) {
            case '清理缓存';
                Sys::cache()->clear();
                $this->output->success('缓存已清理');
                break;
            case '取消';
                $this->output->warning('操作已取消');
                break;
        }
    }
}